/**
 * Filename: BaseFragmentActivity.java
 * @author  Firefly
 * @contact postfirefly@163.com
 * @time    2016/3/9 4:19 
 */
package com.github.postsanf.yinian;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;

import com.github.postsanf.yinian.utils.Logger;
import com.github.postsanf.yinian.utils.ToastUtils;
import com.google.gson.Gson;
import com.litesuits.http.HttpConfig;
import com.litesuits.http.LiteHttp;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * 基类初始化操作
 */
public class BaseFragmentActivity extends FragmentActivity
{
	protected String 						TAG;						// 标识
	protected BaseApplication 				application;				// 应用主体
	protected LiteHttp 						liteHttp;					// 网络访问
	protected ImageLoader 					imageLoader;				// 图片加载
	protected Gson 							gson;						// json利器
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		TAG 				= this.getClass().getSimpleName();
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		application 		= (BaseApplication) getApplication();
		imageLoader 		= ImageLoader.getInstance();
		gson 				= new Gson();
		liteHttp 			= LiteHttp.newApacheHttpClient(new HttpConfig(this));
	}

	protected void intent2Activity(Class<? extends Activity> tarActivity) {
		Intent intent = new Intent(this, tarActivity);
		startActivity(intent);
	}
	// 显示Toast
	protected void showToast(String msg)
	{
		ToastUtils.showToast(this, msg, Toast.LENGTH_SHORT);
	}
	// 输出日志
	protected void showLog(String msg)
	{
		Logger.show(TAG, msg);
	}
}
